/*
 *  $Id: NamePhrasePart.cs 1183 2010-11-10 17:04:21Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008-2010 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

namespace Ragima.Languages.PhraseParts {
    /// <summary>
    /// Часть фразы: имя на английском языке.
    /// </summary>
    public class EnglishNamePhrasePart : NamePhrasePart {
        private EnglishCase _nameCase;

        public EnglishNamePhrasePart(int argNum, bool capitalize, EnglishCase nameCase) : base(argNum, capitalize) {
            _nameCase = nameCase;
        }

        protected override void BuildArg(PhraseBuilder builder, INamed arg) {
            var name = arg.Name.GetResource<EnglishName>();
            BuildName(builder, name[_nameCase]);
        }

        protected override void BuildTemplateCase(PhraseBuilder builder) {
            if (_nameCase != EnglishCase.Nominative)
                builder.Text.Append((int) _nameCase);
        }

        public sealed class EnglishNameParser : NameParser<EnglishCase> {
            protected override PhrasePart Create(int argNum, bool capitalize, EnglishCase nameCase) {
                return new EnglishNamePhrasePart(argNum, capitalize, nameCase);
            }
        }
    }
}
